void reverse(int* nums, int begin, int end)
{
    while(begin < end)
    {
        int tem = nums[begin];
        nums[begin] = nums[end];
        nums[end] = tem;

        begin ++;
        end --;
    }

}

void rotate(int* nums, int numsSize, int k){

    k %= numsSize;
    
    reverse(nums,0,numsSize-k-1);
    reverse(nums,numsSize-k,numsSize-1);
    reverse(nums,0,numsSize-1);
}